package com.corticon.dialogs.model;

import java.io.Serializable;

import javax.persistence.Column;
import javax.persistence.Embeddable;

/**
 * The composite id for Locale model.
 *
 * @author Lifan Yang
 */
@Embeddable
public class LocaleId implements Serializable {

    private String countryId;
    private String languageId;

    public LocaleId() {
    }

    public LocaleId(String countryId, String languageId) {
        this.countryId = countryId;
        this.languageId = languageId;
    }

    @Column(name = "countryassoc_code_oid", nullable = false, length = 256)
    public String getCountryId() {
        return countryId;
    }

    public void setCountryId(String countryId) {
        this.countryId = countryId;
    }

    @Column(name = "languageassoc_code_oid", nullable = false, length = 256)
    public String getLanguageId() {
        return languageId;
    }

    public void setLanguageId(String languageId) {
        this.languageId = languageId;
    }

    @Override
    public boolean equals(Object obj) {
        if (this == obj) {
            return true;
        }
        if (obj == null) {
            return false;
        }
        if (!(obj instanceof LocaleId)) {
            return false;
        }
        LocaleId localeId = (LocaleId) obj;

        return localeId.getCountryId().equals(countryId) && localeId.getLanguageId().equals(
            languageId);
    }

    @Override
    public int hashCode() {
        return countryId.hashCode() + languageId.hashCode();
    }
}
